package com.meitu.community.service;

import com.meitu.community.dao.UserDao;
import com.meitu.community.dao.UserDaoImpl;
import com.meitu.community.model.User;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    @Override
    public User findByUser(User checkUser) {
        User user = userDao.findByUsername(checkUser.getUsername());
        if (user == null) {
            throw new RuntimeException("该用户不存在");
        }
        if (user.getPassword() == null || checkUser.getPassword() == null || !user.getPassword().equals(checkUser.getPassword())) {
            throw new RuntimeException("密码错误");
        }
        return user;
    }
}
